#ifndef ELK_DOWNLOAD_ITEM_H
#define ELK_DOWNLOAD_ITEM_H

#include <QFrame>
#include "elk_download_manager.h"

namespace Ui {
class ElkDownloadItem;
}

class ElkDownloadItem : public QFrame
{
    Q_OBJECT

public:
    explicit ElkDownloadItem(QWidget *parent = nullptr);
    ~ElkDownloadItem();

    void attach(ElkDownloadTask *task);

private slots:
    void finished();
    void interrupted();
    void downloadProgress(qint64 bytesReceived, qint64 bytesTotal, qint64 bytesFileSize);

    void urlChanged(const QString &url);
    void fileError(QFile::FileError, const QString &errorString);
    void replyError(QNetworkReply::NetworkError error, const QString &errorString);

    void on_pushButtonPause_clicked();
    void on_pushButtonResume_clicked();
    void on_pushButtonCancel_clicked();
    void on_pushButtonRetry_clicked();
    void on_pushButtonDelete_clicked();

private:
    void resetDisply();

    Ui::ElkDownloadItem *ui;
    ElkDownloadTask *task_ = nullptr;
};

#endif // ELK_DOWNLOAD_ITEM_H
